<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //数组解构
      // 1) 基本解构
      var [a, b, c] = [1, 2, 3]
      var arr = [{ name: 'banner' }, { name: '列表' }, { nav: '导航' }]
      var [banner, list, nav] = arr
      console.log(banner, list, nav)
      //2)可嵌套 解构
      var [x, [[y], z]] = [5, [[6], 7]]
      console.log(x, y, z)
      //3) 可忽略
      var [m, , n] = [7, 8, 9]
      console.log(m, n)
      //不完全解构
      let [d = 1, s] = [] // d = 1, s = undefined
      console.log(d, s)
      //剩余运算符   ...  扩展运算符
      var [name, age, ...num] = ['老王', '18', 'c', 'd', 'E']
      console.log(name, age, num)
      // 字符串解构赋值
      let [a, b, c, d, e] = 'hello'
      // a = 'h'
      // b = 'e'
      // c = 'l'
      // d = 'l'
      // e = 'o'
      let [a = 3, b = a] = [1, 2] // a = 1, b = 2
      //
    </script>
  </body>
</html>
